<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>选择人员</title>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <link rel="stylesheet" href="../css/page_css/util.css">
</head>

<body>
    <div class="mui-content">
        <ul class="mui-table-view01">
            <li class="search-cell">
                <div class="mui-input-row mui-search">
                    <input type="search" id="searchText" class="mui-input-clear" placeholder="请输入姓名或编号"><span class="mui-icon mui-icon-clear mui-hidden"></span><span class="mui-placeholder"><span></span></span>
                </div>
                <div class="mui-btn mui-btn-primary" onclick="Search()">
                    搜索
                </div>
            </li>
        </ul>
        <ul class="mui-table-view" id="PropertyContent">
            <script type="text/template" id="itemslist">
                {{each datas as item i}}
                <li class="mui-table-view-cell mui-radio mui-left">
                    <input name="sel_property_radio" type="radio" onchange="ChProperty('{{item.userid}}','{{item.displayname}}','{{item.rate}}')">
                    <div class="list_item">
                        <div class="flex_center_between">
                            <p class="flex_first">
                                <label for="" class="no-padding width_auto">人员:&nbsp;&nbsp;</label>
                                <span>{{item.userid}}/{{item.displayname}}</span>
                            </p>
                        </div>
                        <div class="flex_center_between">
                            <p class="flex_first">
                                <label for="" class="no-padding width_auto">头衔:&nbsp;&nbsp;</label>
                                <span>{{item.title}}/{{item.titleName}}</span>
                            </p>
                        </div>
                    </div>
                </li>
                {{/each}}
            </script>
        </ul>

    </div>
    <script type="text/javascript" src="../script/api.js"></script>
    <script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
    <script src="../script/template.js" type="text/javascript" charset="utf-8"></script>
    <script>
        var page = 1;
        var loadEnd = false;
        var Susername = '',
            userID = '',
            userName = ''
            rate = ''
        apiready = function() {
            onLoadData(page, false);
            scrollToBottomHandler(function() {
                if (!loadEnd) { // 没有结束时继续加载
                    page++;
                    onLoadData(page, true);
                } else { // 告诉到底了
                    EndToast('到底了');
                }
            })
            Refresh(function() {
                loadEnd = false;
                page = 1;
                onLoadData(page, false);
            });

            api.addEventListener({
                name: 'navitembtn'
            }, function(ret, err) {
                if (ret.type == 'right') {
                  if($api.dom("input[type='radio']:checked") == null){
                    api.toast({
      						    msg: '请选择一项!',
      						    duration: 2000,
      						    location: 'middle'
      							});
                    return false
                  }
                  if (api.pageParam.manager && api.pageParam.manager == true) {
                    api.sendEvent({
                        name: 'ManagerCh',
                        extra: {
                            userID: userID,
                            userName: userName,
                            rate: rate
                        }
                    });
                  }
                  if (api.pageParam.lead && api.pageParam.lead == true) {
                  	api.sendEvent({
	                      name: 'lead',
	                      extra: {
	                          userID: userID,
	                          userName: userName
	                      }
	                  });
                  }
                  setTimeout(function() {
                      api.closeWin();
                  }, 100)
                }
            })
        }

        function onLoadData(page, load) {
            Susername = $api.val($api.byId('searchText'));
            ajaxrd("selectUserRateList", {
                username: Susername,
                pageNo: page,
                pageSize: 10
            }, function(ret, err) {
                api.refreshHeaderLoadDone();
                AddData('itemslist', 'PropertyContent', ret.list, load);
                if (ret.list.length < 10) {
                    loadEnd = true
                }
            })
        }
        var ChProperty = function(id, name, rateVal) {
            userID = id
            userName = name
            rate = rateVal
        }
    </script>
</body>

</html>
